"""幕学网 URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""

from django.conf.urls import url,include
from django.views.generic import TemplateView
from users.views import IndexView
import xadmin
from django.views.static import serve # 处理Django静态文件
from django.conf import settings
from users.views import LoginView,RegisterView,ActiveView,LogoutView,ForgetPwdView,ResetView,ModifyPwdView

urlpatterns = [
    # url(r'^xadmin/', xadmin.site.urls),
    url(r'^captcha/',include('captcha.urls')),
    # 后台页面
    url(r'^xadmin/', xadmin.site.urls),
    # 主页面
    url('^$', IndexView.as_view(), name="index"),
    # 登录页面
    url(r'^login/$', LoginView.as_view(),name='login'),
    # 用户退出
    url(r'^logout/$', LogoutView.as_view(),name='logout'),
    # 注册页面
    url(r'^register/$', RegisterView.as_view(),name='register'),
    url(r'^active/(?P<active_code>.*)/$',ActiveView.as_view(),name='user_active'),
    # 找回密码/修改密码
    url(r'^forgetpwd/$',ForgetPwdView.as_view(),name='forget_pwd'),
    url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"),
    url(r'^modify_pwd/$', ModifyPwdView.as_view(), name="modify_pwd"),

    # 课程机构urls
    url(r'^org/',include('organization.urls',namespace='org')),
    # 上传的文件的访问处理函数
    url(r'^media/(?P<path>.*)$',serve,{'document_root':settings.MEDIA_ROOT}),
    url(r'^static/(?P<path>.*)$',  serve, {"document_root":settings.STATIC_ROOT}),

    # 课程urls
    url(r'^course/', include('courses.urls', namespace='course')),
    # 个人中心
    url(r'^users/', include('users.urls', namespace="users")),

]
# 全局404页面配置
handler404 = 'users.views.page_not_found'
handler500 = 'users.views.page_error'